package com.ag.contactTree.service;

import java.util.List;

import javax.annotation.Resource;

import com.ag.contactTree.MedicineTree;
import com.ag.contactTree.TreeNode;
import com.ag.zhh.dao.UserDeptDAO;
import com.ag.zhh.vo.UserDept;

//OA通信录的树
public class OATreeService extends TreeService{
	
	@Resource(name="UserDeptDAO")
	private UserDeptDAO deptDao;
	
	//增加树的结点
	public void addTreeNodeByDept(UserDept dept)
	{
		MedicineTree.getInstance(deptDao).addDeptTreeNode(dept);
	}
	/* 返回药监部门的树 */
	public MedicineTree getMedicineTree() {
		return MedicineTree.getInstance(deptDao);
	}
	//返回药监内部树的树根
	public TreeNode getMedicineTreeRoot() {
        System.out.println("OAtree:          "+MedicineTree.getInstance(deptDao).getRootNode());
		return MedicineTree.getInstance(deptDao).getRootNode();
	}
	public List<TreeNode> getChildrenByFDId(String nodeId) {
		TreeNode node = getTreeNodeById(nodeId);
		List<TreeNode> list = null;
		if (node != null) {
			list = node.getChildren();
		}
		return list;
	}
	
	
	public TreeNode getTreeNodeById(String nodeId) {
		TreeNode node = null;
		try {
			System.out.println("**********\t\t\tTreeService: " + nodeId+ "\t\t\t*********************");
			node = getMedicineTreeNodeById(nodeId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return node;
	}
	//返回结点
	public TreeNode getMedicineTreeNodeById(String nodeId) {
		TreeNode node = MedicineTree.getInstance(deptDao).getTreeNode(nodeId);
		return node;
	}
	

}
